package com.qingcloud.adminbackend.controller;

import com.qingcloud.adminbackend.base.AjaxResult;
import com.qingcloud.adminbackend.constant.WamingConstant;
import com.qingcloud.adminbackend.entity.product.ProductDTO;
import com.qingcloud.adminbackend.entity.product.ProductTypeDTO;
import com.qingcloud.adminbackend.service.ISysProductService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 产品管理
 *
 * @author liyuhong
 */
@RestController
@RequestMapping("/product")
public class ProductController {

    @Resource
    private ISysProductService sysProductService;


    @ApiOperation(value = "设备池内的产品", notes = "产品", response = ProductDTO.class)
    @PostMapping("/products")
    public AjaxResult products() {
        return new AjaxResult(WamingConstant.SUCCESS, "", sysProductService.products());
    }

    @ApiOperation(value = "设备池内的产品型号", notes = "产品型号", response = ProductTypeDTO.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "productId", value = "产品id", dataType = "string", paramType = "query", defaultValue = "1")
    })
    @PostMapping("/productTypes")
    public AjaxResult productTypes(String productId) {
        return new AjaxResult(WamingConstant.SUCCESS, "", sysProductService.productTypes(productId));
    }

    @ApiOperation(value = "产品型号查询产品信息", notes = "产品型号查询产品信息", response = ProductTypeDTO.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "productId", value = "产品(1:室内通用；2：室内装修）", dataType = "string", paramType = "query", defaultValue = "1")
    })
    @PostMapping("/productTypies")
    public AjaxResult productTypies(String productId) {
        return new AjaxResult(WamingConstant.SUCCESS, "", sysProductService.productTypies(productId));
    }
}
